Add unit tests for Metadata reserved-key blocking, write limiter, and composite properties#2948
Open
vasiliy-mikhailov wants to merge 1 commit into
Open
Add unit tests for Metadata reserved-key blocking, write limiter, and composite properties#2948vasiliy-mikhailov wants to merge 1 commit into
vasiliy-mikhailov wants to merge 1 commit into
Conversation
6917198 to
99fb891
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Results
Scope: module
tika-core, target production classorg.apache.tika.metadata.Metadata, testsorg.apache.tika.metadata.TestMetadata. Measured with PIT 1.15.2 (junit5 plugin) under JDK 17, cleantest-compileforced before each run.The added tests kill 4 additional Metadata mutants and eliminate 2 survivors.
What this adds
Six focused unit tests on
Metadata, each asserting observable behavior or a documented contract:testValueDistinctMetadataNotEqual- twoMetadatainstances differing only in a value under the same key are not equal (value-basedequalscontract).testReservedKeyBlockedOnUntrustedMetadata- a reservedX-TIKA:key (built fromTikaCoreProperties.TIKA_META_PREFIX) added via a String write to an untrusted (default) instance is dropped, so untrusted callers cannot inject reserved keys.testReservedKeyAllowedOnTrustedMetadata- aftersetTrusted(true), the same reserved key is accepted.testWriteLimiterBlocksSet- a limiter that drops everything preventssetfrom persisting, so persistence stays under the limiter's control.testWriteLimiterInvokedOnSet-set(String, String)delegates to the limiter with the exact field and value (asserted via a recording spy limiter, not by re-reading a value the limiter itself wrote).testWriteLimiterInvokedOnSetProperty-set(Property, String)delegates to the limiter using the property'sgetName()and the given value.Scope
Tests-only. One file changed:
tika-core/src/test/java/org/apache/tika/metadata/TestMetadata.java(121 insertions, 0 deletions vs base). No production code, no fixtures, no build changes; Apache license headers unchanged.Disclosure
This PR was generated with an AI-assisted pipeline built around mutation testing (PIT). The pipeline mutates the target class (flipping conditions and changing boundary/edge cases) and runs the existing tests against each mutant; where a mutant survives (the existing tests do not catch that edge case), it writes a focused test for that case and reruns PIT to confirm the new test actually kills that specific mutant.